<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Cocos2d-x 多分辨率适配完全解析 | 泰然网</title>

<link rel="stylesheet" href="http://www.ityran.com/wp-content/plugins/sitepress-multilingual-cms/res/css/language-selector.css?v=2.8.1" type="text/css" media="all" />

<meta name="description" content="u0u0（微博）原创，首发于泰然，转载请著名出处。" />
<meta name="keywords" content="Cocos2D-x,多分辨率" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="http://www.ityran.com/wp-content/themes/Loostrive/css/kube.css" />
<link rel="stylesheet" type="text/css" href="http://www.ityran.com/wp-content/themes/Loostrive/css/reset.css" />
<link rel="stylesheet" type="text/css" href="http://www.ityran.com/wp-content/themes/Loostrive/images/lightbox/pirobox.css" target="_blank" />
<link rel="alternate" type="application/rss+xml" title="泰然网 RSS Feed" href="http://www.ityran.com/feed" />
<link rel="alternate" type="application/atom+xml" title="泰然网 Atom Feed" href="http://www.ityran.com/feed/atom" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="pingback" href="http://www.ityran.com/xmlrpc.php" />

<!-- SEO Ultimate (http://www.seodesignsolutions.com/wordpress-seo/) -->
	<meta name="keywords" content="cocos2d-x,多分辨率,height,width,kresolutionfixedwidth" />
	<meta prefix="og: http://ogp.me/ns#" property="og:type" content="article" />
	<meta prefix="og: http://ogp.me/ns#" property="og:title" content="Cocos2d-x 多分辨率适配完全解析" />
	<meta prefix="og: http://ogp.me/ns#" property="og:url" content="http://www.ityran.com/archives/4809" />
	<meta property="article:published_time" content="2013-08-04" />
	<meta property="article:modified_time" content="2013-08-14" />
	<meta property="article:author" content="http://www.ityran.com/archives/author/u0u0" />
	<meta property="article:section" content="cocos2d-x" />
	<meta property="article:tag" content="Cocos2D-x" />
	<meta property="article:tag" content="多分辨率" />
	<meta prefix="og: http://ogp.me/ns#" property="og:site_name" content="泰然网" />
	<meta name="twitter:card" content="summary" />
<!-- /SEO Ultimate -->

<link rel='stylesheet' id='wpml-cms-nav-css-css'  href='http://www.ityran.com/wp-content/plugins/wpml-cms-nav/res/css/navigation.css?ver=1.3' type='text/css' media='all' />
<link rel='stylesheet' id='cms-navigation-style-base-css'  href='http://www.ityran.com/wp-content/plugins/wpml-cms-nav/res/css/cms-navigation-base.css?ver=1.3' type='text/css' media='screen' />
<link rel='stylesheet' id='cms-navigation-style-css'  href='http://www.ityran.com/wp-content/plugins/wpml-cms-nav/res/css/cms-navigation.css?ver=1.3' type='text/css' media='screen' />
<script type="text/javascript">
var duoshuoQuery = {"short_name":"ityran","sso":{"login":"http:\/\/www.ityran.com\/wp-login.php?action=duoshuo_login","logout":"http:\/\/www.ityran.com\/wp-login.php?action=logout&_wpnonce=c559d38b8b"},"theme":"default","stylePatch":"wordpress\/Loostrive"};
duoshuoQuery.sso.login += '&redirect_to=' + encodeURIComponent(window.location.href);
duoshuoQuery.sso.logout += '&redirect_to=' + encodeURIComponent(window.location.href);
</script>
<script type="text/javascript" src="http://static.duoshuo.com/embed.js" charset="UTF-8" async="async"></script>
<script type='text/javascript' src='http://www.ityran.com/wp-content/themes/Loostrive/js/jquery.min.js?ver=3.8'></script>
<script type='text/javascript' src='http://www.ityran.com/wp-content/plugins/sitepress-multilingual-cms/res/js/jquery.cookie.js?ver=2.8.1'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var wpml_browser_redirect_params = {"pageLanguage":"zh-hans","languageUrls":{"zh-hans":"http:\/\/www.ityran.com\/archives\/4809","en":"http:\/\/www.ityran.com\/en\/archives\/4914"},"cookie":{"name":"_icl_visitor_lang_js","domain":"www.ityran.com","path":"\/","expiration":24}};
/* ]]> */
</script>
<script type='text/javascript' src='http://www.ityran.com/wp-content/plugins/sitepress-multilingual-cms/res/js/browser-redirect.js?ver=2.8.1'></script>
<link rel='prev' title='CCScrollView 实现帮助界面、关卡选择' href='http://www.ityran.com/archives/4750' />
<link rel='next' title='如何使用 CocoStudio 场景编辑器制作《魔卡幻想》主界面' href='http://www.ityran.com/archives/4765' />
<link rel='shortlink' href='http://www.ityran.com/?p=4809' />
<script type="text/javascript">var icl_lang = 'zh-hans';var icl_home = 'http://www.ityran.com/';</script>
<script type="text/javascript" src="http://www.ityran.com/wp-content/plugins/sitepress-multilingual-cms/res/js/sitepress.js"></script>
<meta name="generator" content="WPML ver:2.8.1 stt:61,1;0" />
<link rel="alternate" hreflang="en-US" href="http://www.ityran.com/en/archives/4914" />
<link rel="stylesheet" type="text/css" href="http://www.ityran.com/wp-content/plugins/wp-code-highlight/css/wp-code-highlight.css" media="screen" />
<link rel="stylesheet" type="text/css" href="http://www.ityran.com/wp-content/themes/Loostrive/css/style/blue.css" />

<style type="text/css">#lang_sel_footer a, #lang_sel_footer a.lang_sel_sel, #lang_sel_footer a.lang_sel_sel:visited{color:#ffffff;}#lang_sel_footer a:hover, #lang_sel_footer a.lang_sel_sel:hover{color:#000000;}#lang_sel_footer a.lang_sel_sel, #lang_sel_footer a.lang_sel_sel:visited{background-color:#95bedd;}#lang_sel_footer a.lang_sel_sel:hover{background-color:#95bedd;}#lang_sel_footer ul a, #lang_sel_footer ul a:visited{color:#000000;}#lang_sel_footer ul a:hover{color:#ffffff;}#lang_sel_footer ul a, #lang_sel_footer ul a:visited{background-color:#cbddeb;}#lang_sel_footer ul a:hover{background-color:#95bedd;}#lang_sel_footer{border-color:#0099cc;}#lang_sel_footer{background-color:#cbddeb;}</style>
<!--[if lt IE 9]>
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body  class="custom-background">
		<div id="head" class="row">
			<div class="container row">
            	<div class="row">
					<div id="topbar">
						                    </div>
					<div id="rss">
                    	<ul>
							<li><a href="http://www.ityran.com/feed" target="_blank" class="icon1" title="欢迎订阅泰然网"></a></li>
														<li><a href="/sitemap_baidu.xml" target="_blank" class="icon5" title="百度站点地图"></a></li>							 														<li><a href="http://e.weibo.com/ityran" target="_blank" class="icon3" title="我的新浪微博" rel="nofollow"></a></li>														<li><a href="/sitemap.xml" target="_blank" class="icon6" title="站点地图"></a></li>							<li><a href="http://mail.qq.com/cgi-bin/feed?u=http://www.ityran.com/feed" target="_blank" class="icon4" title="用QQ邮箱阅读空间订阅本站" rel="nofollow"></a></li>
						</ul>
                    </div>
                 </div>
             </div>
					<div class="clear"></div>
				<div class="container">
					<div id="blogname" class="third">
                    	<a href="http://www.ityran.com/" title="泰然网">                        <img src="/logo.png" alt="泰然网" /></a>
                    </div>
                 	 
                </div>
				<div class="clear"></div>
		</div>
		<div class="mainmenus container">
			<div class="mainmenu">
				<div class="topnav">
                     <!-- menus START -->
                    <script type="text/javascript" language="javascript">
                     function gaoliangfenlei()
                     { 
                      var nav = document.getElementById("menus");    
                      var links = nav.getElementsByTagName("li");    
                      var lilen = nav.getElementsByTagName("a");    
                      var currenturl = document.location.href;    
                      var last = 0;    
                      for (var i=0;i<links.length;i++)    
                      {    
                       var linkurl = lilen[i].getAttribute("href");    
                       if(currenturl.indexOf(linkurl)!=-1)    
                       {    
                        last = i;    
                       }    
                      } 
                     links[last].className = "current_page_item";
                     }
                    </script> 
                    <script type="text/javascript" language="javascript">
                     function gaoliangwenzhangfenlei(catname)
                     {
                      var caidan ="" ;
                      var fenleiming ="" ;
                      var nav = document.getElementById("menus");    
                      var links = nav.getElementsByTagName("li");  
                      var as = nav.getElementsByTagName("a");  
                      var last = 0;    
                      for (var i=0;i<links.length;i++)    
                      {    
                       var li = links[i].innerHTML;
                       var ai=as[i].innerHTML;        
                       if(ai==catname)    
                       {    
                        last = i;
                        links[last].className = "current_page_item";
                       } 
                      }         
                     }
                    </script> 
					                    <ul id="menus">
						<li id="menu-item-2840" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-2840"><a href="http://www.ityran.com/">泰然首页</a></li>
<li id="menu-item-3273" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3273"><a href="http://www.ityran.com/tutorials">教程汇总</a></li>
<li id="menu-item-2841" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-2841"><a href="http://bbs.ityran.com/forum.php">泰然论坛</a></li>
<li id="menu-item-1340" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1340"><a href="http://bbs.ityran.com/forum-61-1.html">代码仓库</a></li>
<li id="menu-item-5082" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-5082"><a href="http://bbs.ityran.com/forum.php?gid=69">游戏策划</a></li>
<li id="menu-item-5131" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-5131"><a href="http://www.ityran.com/tyranworkshop">泰然工坊</a></li>
<li id="menu-item-2836" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2836"><a href="http://www.ityran.com/about">泰然档案</a></li>
<li id="menu-item-1715" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1715"><a href="http://www.ityran.com/post">投稿箱</a></li>
<script type='text/javascript' language='javascript'>gaoliangwenzhangfenlei('cocos2d-x')</script>                    </ul>
                 <!-- menus END -->                    
                   <div id="select_menu">
					<select onChange="document.location.href=this.options[this.selectedIndex].value;" id="select-menu-nav"><option value="#">导航菜单</option><option   value="http://www.ityran.com/">泰然首页</option><option   value="http://www.ityran.com/tutorials">教程汇总</option><option   value="http://bbs.ityran.com/forum.php">泰然论坛</option><option   value="http://bbs.ityran.com/forum-61-1.html">代码仓库</option><option   value="http://bbs.ityran.com/forum.php?gid=69">游戏策划</option><option   value="http://www.ityran.com/tyranworkshop">泰然工坊</option><option   value="http://www.ityran.com/about">泰然档案</option><option   value="http://www.ityran.com/post">投稿箱</option></select>                            
              	</div>  
            </div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
        <div class="search_phone container">
<div class="search box row">
<div class="search_site">
<form id="searchform" method="get" action="http://www.ityran.com">
		<input type="submit" value="" id="searchsubmit" class="button"/>
		<input type="text" id="s" name="s" value="请输入搜索内容" onfocus="if (value ==\'请输入搜索内容\'){value =\'\'}" onblur="if (value ==\'\'){value=\'请输入搜索内容\'}" x-webkit-speech />
</form></div></div></div>	<div class="container">
		        <div class="row">
			        </div>
   	 	<div id="sidebar">
         
<div class="search box row">
<div class="search_site">
<form id="searchform" method="get" action="http://www.ityran.com">
		<input type="submit" value="" id="searchsubmit" class="button"/>
		<input type="text" id="s" name="s" value="请输入搜索内容" onfocus="if (value =='请输入搜索内容'){value =''}" onblur="if (value ==''){value='请输入搜索内容'}" x-webkit-speech />
</form></div></div>        <div class="widget box row">          <form id="loginform" action="http://www.ityran.com/wp-login.php" method="post"><h3>用户登录</h3>
<div class="loginl">
<p>
<label>用户名</label><input class="login" type="text" name="log" id="log" value="" size="12" />
</p>
<p>
<label>密　码</label><input class="login" type="password" name="pwd" id="pwd" value="" size="12" />
</p></div>
<div class="loginr">
<input class="denglu btn" type="submit" name="submit" value="登 陆" /></div><div class="clear"></div><p><a class="register" href="http://www.ityran.com/wp-login.php?action=register">用户注册</a><label><input id="comment_mail_notify" type="checkbox" name="rememberme" value="forever" />记住我 </label>
</p>
<p>
<input type="hidden" name="redirect_to" value="/archives/4809"/>
</p>
</form>
<div class="clear"></div> </div><div class="widget box row"><h3>泰然官方微博</h3>			<div class="textwidget"><iframe width="100%" height="74" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=117&fansRow=2&ptype=1&speed=0&skin=1&isTitle=0&noborder=0&isWeibo=0&isFans=0&uid=2703776721&verifier=26e46324&dpc=1"></iframe></div>
		</div><div class="widget box row"><h3>泰然微信公众账号</h3>			<div class="textwidget"><div style="text-align:center;">
					<img src="http://www.ityran.com/wp-content/uploads/2013/06/qrcode_for_gh_312db0974be6_430-150x150.jpg" alt="扫描泰然网微信二维码">
</div></div>
		</div><div class="widget box row"><h3>泰然技术群</h3>			<div class="textwidget"><h2>
<p align="left" style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-size: x-large; "><span style="color: rgb(255, 102, 0); ">泰然骷髅会：</span></span></p>
<font face="Verdana, Geneva, Arial, Helvetica, sans-serif">
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-size: smaller; ">销售技巧，营销策略，app周边：</span><span style="font-size: 15px;"><br />
</span></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-size: smaller; ">泰然骷髅会非公开群：629***17</span></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-size: 15px; ">需要验证方式</span><a href="http://www.ityran.com/thread-447-1-1.html" target="_blank" style="font-size: 15px; ">点此观看</a>&nbsp;，<span style="font-size: smaller; ">有app上线的同学也可联系Iven手动加入；</span></p>
<div><span style="font-size: x-large; "><span style="color: rgb(255, 102, 0); "><strong>普通技术群：</strong></span></span></div>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strike><span style="font-size: smaller; "><span style="color: rgb(153, 153, 153); ">1群：166128264（已满）</span></span></strike></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strike><span style="font-size: smaller; "><span style="color: rgb(153, 153, 153); "> 2群：62040758 （已满）</span></span></strike></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strike><span style="font-size: smaller; "><span style="color: rgb(153, 153, 153); "> 3群：142908600（已满） </span></span></strike></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strike><span style="font-size: smaller; "><span style="color: rgb(153, 153, 153); ">4群：172800020 （已满） </span></span></strike></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strike><span style="font-size: smaller; "><span style="color: rgb(153, 153, 153); ">5群：190864061 （已满）</span></span></strike></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-size: smaller; ">泰然论坛开发综合交流（6群）： 100612730（1000人群审核严格！）</span></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-size: smaller; ">opengl ES专项群（7群）：152567522(1000人)</span></p>
<p align="left" style="font-size: large; word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-size: smaller; ">Cocos2d-x专项群（8群）：146069008(1000人)</span></p>
</font></h2></div>
		</div>		  <div class="widget box row">
		  	<div id="tab-title">
				<div class="tab">
					<ul id="tabnav">
						<li>最新文章</li>
						<li class="selected">热评文章</li>
						<li>随机文章</li>
					</ul>
				</div>
				<div class="clear"></div>
			</div>
			<div id="tab-content">
				<ul class="hide">	<li><a href='http://www.ityran.com/archives/5431'>在cocos2d-x 3.0中使用物理引擎</a></li>
	<li><a href='http://www.ityran.com/archives/5428'>【视频教程】理解 cocos2d-x内存管理</a></li>
	<li><a href='http://www.ityran.com/archives/5365'>iOS 7教程-Storyboards Part1</a></li>
	<li><a href='http://www.ityran.com/archives/5361'>如何优雅的管理游戏资源</a></li>
	<li><a href='http://www.ityran.com/archives/5276'>Cocos2d: Working with Sprites</a></li>
	<li><a href='http://www.ityran.com/archives/5296'>Lua脚本在C++下的舞步(入门指引)转</a></li>
	<li><a href='http://www.ityran.com/archives/5257'>Sprite Kit教程：动画和纹理图集</a></li>
	<li><a href='http://www.ityran.com/archives/5279'>玩转 Cocos2d-x 脚本引擎</a></li>
	<li><a href='http://www.ityran.com/archives/5216'>Sprite Kit教程：初窥门径</a></li>
	<li><a href='http://www.ityran.com/archives/5185'>JSB内存管理</a></li>
</ul>
				<ul>
<li><a href= "http://www.ityran.com/archives/5110" target="_blank" rel="bookmark" title="《跑酷》Starter Kit (58条评论)" >《跑酷》Starter Kit</a></li>
<li><a href= "http://www.ityran.com/archives/4854" target="_blank" rel="bookmark" title="Cocos2d-x 弹出对话框的设计与实现 (24条评论)" >Cocos2d-x 弹出对话框的设计与实现</a></li>
<li><a href= "http://www.ityran.com/archives/3210" target="_blank" rel="bookmark" title="战争迷雾效果 第1章_要探索，不要地图全开！ (17条评论)" >战争迷雾效果 第1章_要探索，不要地图全开！</a></li>
<li><a href= "http://www.ityran.com/archives/4018" target="_blank" rel="bookmark" title="Cocos2d-x 屏幕适配新解 (17条评论)" >Cocos2d-x 屏幕适配新解</a></li>
<li><a href= "http://www.ityran.com/archives/4100" target="_blank" rel="bookmark" title="【无间落叶 专栏】Cocos2d-x 内存管理浅说 (13条评论)" >【无间落叶 专栏】Cocos2d-x 内存管理浅说</a></li>
<li><a href= "http://www.ityran.com/archives/4126" target="_blank" rel="bookmark" title="【笨木头原创专栏】一个函供应多个菜单回调——UserObject自定义数据 (12条评论)" >【笨木头原创专栏】一个函供应多个菜单回调——</a></li>
<li><a href= "http://www.ityran.com/archives/3950" target="_blank" rel="bookmark" title="TexturePacker 图片加密 (11条评论)" >TexturePacker 图片加密</a></li>
<li><a href= "http://www.ityran.com/archives/4676" target="_blank" rel="bookmark" title="如何使用 CocoStudio UI 编辑器实现《乱斗堂》设置界面 (11条评论)" >如何使用 CocoStudio UI 编辑器实现《乱斗堂</a></li>
<li><a href= "http://www.ityran.com/archives/4902" target="_blank" rel="bookmark" title="Cocos2d-x Js Binding 的手动绑定实现 (11条评论)" >Cocos2d-x Js Binding 的手动绑定实现</a></li>
<li><a href= "http://www.ityran.com/archives/2936" target="_blank" rel="bookmark" title="泰然有奖问卷调查《cocos2d权威指南》免费送 (10条评论)" >泰然有奖问卷调查《cocos2d权威指南》免费送</a></li></ul>
				<ul class="hide">
				                	<li><a href="http://www.ityran.com/archives/1354" title="在OpenGL ES 2.0中通过触摸来旋转3D对象 的文章">在OpenGL ES 2.0中通过触摸来旋转3D对象</a></li>
				                	<li><a href="http://www.ityran.com/archives/2728" title="cocos2d-x学习笔记06：如何将win32移植到android 的文章">cocos2d-x学习笔记06：如何将win32移植到android</a></li>
				                	<li><a href="http://www.ityran.com/archives/4619" title="CocoStudio UI 编辑器的使用 的文章">CocoStudio UI 编辑器的使用</a></li>
				                	<li><a href="http://www.ityran.com/archives/1024" title="如何给你的iOS游戏加入动态背景音乐 的文章">如何给你的iOS游戏加入动态背景音乐</a></li>
				                	<li><a href="http://www.ityran.com/archives/949" title="如何设计开发iPhone塔防游戏9-劳命伤财 的文章">如何设计开发iPhone塔防游戏9-劳命伤财</a></li>
				                	<li><a href="http://www.ityran.com/archives/5257" title="Sprite Kit教程：动画和纹理图集 的文章">Sprite Kit教程：动画和纹理图集</a></li>
				                	<li><a href="http://www.ityran.com/archives/4512" title="初识block 的文章">初识block</a></li>
				                	<li><a href="http://www.ityran.com/archives/2911" title="【视频教程】泰然cocos2d-x多分辨率适配方案 的文章">【视频教程】泰然cocos2d-x多分辨率适配方案</a></li>
				                	<li><a href="http://www.ityran.com/archives/2043" title="cocos2d-x设计模式发掘之三：管理者模式 的文章">cocos2d-x设计模式发掘之三：管理者模式</a></li>
				                	<li><a href="http://www.ityran.com/archives/2245" title="从零开始使用Xcode自动化测试 Part 1/2 的文章">从零开始使用Xcode自动化测试 Part 1/2</a></li>
				                </ul>
             </div>
          </div>
<div class="widget box row"><h3>Categories</h3>		<ul>
	<li class="cat-item cat-item-9"><a href="http://www.ityran.com/archives/category/cocoa-touch" title="查看Cocoa Touch下的所有文章">Cocoa Touch</a> (26)
</li>
	<li class="cat-item cat-item-71"><a href="http://www.ityran.com/archives/category/cocos2d-html5" title="查看cocos2D-HTML5下的所有文章">cocos2D-HTML5</a> (4)
</li>
	<li class="cat-item cat-item-7"><a href="http://www.ityran.com/archives/category/cocos2d-iphone" title="查看cocos2d-iPhone下的所有文章">cocos2d-iPhone</a> (38)
</li>
	<li class="cat-item cat-item-8"><a href="http://www.ityran.com/archives/category/cocos2d-x" title="查看cocos2d-x下的所有文章">cocos2d-x</a> (141)
<ul class='children'>
	<li class="cat-item cat-item-151"><a href="http://www.ityran.com/archives/category/cocos2d-x/cocos2d-x%e5%ae%98%e6%96%b9%e6%96%87%e6%a1%a3" title="查看cocos2d-x官方文档下的所有文章">cocos2d-x官方文档</a> (46)
</li>
</ul>
</li>
	<li class="cat-item cat-item-77"><a href="http://www.ityran.com/archives/category/ios%e5%bc%80%e5%8f%91%e5%9f%ba%e7%a1%80" title="查看iOS开发基础下的所有文章">iOS开发基础</a> (10)
</li>
	<li class="cat-item cat-item-4"><a href="http://www.ityran.com/archives/category/opengl-es" title="查看OpenGL ES下的所有文章">OpenGL ES</a> (2)
</li>
	<li class="cat-item cat-item-216"><a href="http://www.ityran.com/archives/category/sprite-kit" title="Sprite Kit文章，Sprite Kit教程">Sprite Kit</a> (2)
</li>
	<li class="cat-item cat-item-213"><a href="http://www.ityran.com/archives/category/starter-kit" title="查看Starter Kit下的所有文章">Starter Kit</a> (1)
</li>
	<li class="cat-item cat-item-10"><a href="http://www.ityran.com/archives/category/other-tutorials" title="查看其他文章下的所有文章">其他文章</a> (31)
</li>
	<li class="cat-item cat-item-170"><a href="http://www.ityran.com/archives/category/navi" title="泰然教程文章导航">文章导航</a> (4)
</li>
	<li class="cat-item cat-item-1"><a href="http://www.ityran.com/archives/category/ityran" title="查看泰然官方下的所有文章">泰然官方</a> (22)
</li>
	<li class="cat-item cat-item-128"><a href="http://www.ityran.com/archives/category/%e8%a7%86%e9%a2%91%e6%95%99%e7%a8%8b" title="查看视频教程下的所有文章">视频教程</a> (22)
</li>
		</ul>
</div><div class="widget box row"><h3>标签</h3><div class="tagcloud"><a href='http://www.ityran.com/archives/tag/2d%e6%a8%aa%e7%89%88%e6%a0%bc%e6%96%97' class='tag-link-111' title='3个话题' style='font-size: 11pt;'>2D横版格斗</a>
<a href='http://www.ityran.com/archives/tag/arc%e4%b9%8bproperty%e4%bd%bf%e7%94%a8' class='tag-link-56' title='1个话题' style='font-size: 8pt;'>ARC之@property使用</a>
<a href='http://www.ityran.com/archives/tag/arc%e6%98%af%e4%bb%80%e4%b9%88' class='tag-link-55' title='1个话题' style='font-size: 8pt;'>ARC是什么</a>
<a href='http://www.ityran.com/archives/tag/block' class='tag-link-51' title='4个话题' style='font-size: 12pt;'>Block</a>
<a href='http://www.ityran.com/archives/tag/block%e5%86%85%e5%ad%98%e7%ae%a1%e7%90%86' class='tag-link-53' title='1个话题' style='font-size: 8pt;'>block内存管理</a>
<a href='http://www.ityran.com/archives/tag/box2d' class='tag-link-85' title='2个话题' style='font-size: 9.8pt;'>Box2D</a>
<a href='http://www.ityran.com/archives/tag/coco2d-x' class='tag-link-129' title='3个话题' style='font-size: 11pt;'>coco2d-x</a>
<a href='http://www.ityran.com/archives/tag/cocos2d' class='tag-link-65' title='10个话题' style='font-size: 15.4pt;'>cocos2d</a>
<a href='http://www.ityran.com/archives/tag/cocos2d-x-2' class='tag-link-96' title='49个话题' style='font-size: 22pt;'>Cocos2D-x</a>
<a href='http://www.ityran.com/archives/tag/cocos2d-x%e5%ae%98%e6%96%b9%e6%96%87%e6%a1%a3' class='tag-link-151' title='10个话题' style='font-size: 15.4pt;'>cocos2d-x官方文档</a>
<a href='http://www.ityran.com/archives/tag/cocos2d-x%e6%95%99%e7%a8%8b' class='tag-link-49' title='3个话题' style='font-size: 11pt;'>cocos2d-x教程</a>
<a href='http://www.ityran.com/archives/tag/cocos2d%e6%95%99%e7%a8%8b' class='tag-link-45' title='19个话题' style='font-size: 18pt;'>Cocos2D教程</a>
<a href='http://www.ityran.com/archives/tag/cocosbuilder' class='tag-link-113' title='4个话题' style='font-size: 12pt;'>CocosBuilder</a>
<a href='http://www.ityran.com/archives/tag/ios' class='tag-link-205' title='2个话题' style='font-size: 9.8pt;'>iOS</a>
<a href='http://www.ityran.com/archives/tag/ios7' class='tag-link-203' title='5个话题' style='font-size: 12.8pt;'>iOS7</a>
<a href='http://www.ityran.com/archives/tag/ios%e9%9f%b3%e9%a2%91%e6%95%99%e7%a8%8b' class='tag-link-39' title='1个话题' style='font-size: 8pt;'>iOS音频教程</a>
<a href='http://www.ityran.com/archives/tag/iphone%e5%bc%80%e5%8f%91' class='tag-link-46' title='2个话题' style='font-size: 9.8pt;'>iphone开发</a>
<a href='http://www.ityran.com/archives/tag/iphone%e5%bc%80%e5%8f%91%e4%b9%8b%e6%b7%b1%e5%85%a5%e6%b5%85%e5%87%ba' class='tag-link-54' title='7个话题' style='font-size: 14pt;'>iPhone开发之深入浅出</a>
<a href='http://www.ityran.com/archives/tag/ityran_navigation' class='tag-link-207' title='4个话题' style='font-size: 12pt;'>ityran_navigation</a>
<a href='http://www.ityran.com/archives/tag/jetpack-joyride' class='tag-link-44' title='4个话题' style='font-size: 12pt;'>Jetpack Joyride</a>
<a href='http://www.ityran.com/archives/tag/lua' class='tag-link-200' title='2个话题' style='font-size: 9.8pt;'>lua</a>
<a href='http://www.ityran.com/archives/tag/opengl-es%e6%95%99%e7%a8%8b' class='tag-link-40' title='1个话题' style='font-size: 8pt;'>OpenGL ES教程</a>
<a href='http://www.ityran.com/archives/tag/schedule' class='tag-link-172' title='4个话题' style='font-size: 12pt;'>schedule</a>
<a href='http://www.ityran.com/archives/tag/tiled' class='tag-link-159' title='2个话题' style='font-size: 9.8pt;'>tiled</a>
<a href='http://www.ityran.com/archives/tag/update' class='tag-link-175' title='2个话题' style='font-size: 9.8pt;'>update</a>
<a href='http://www.ityran.com/archives/tag/%e6%8c%87%e4%b8%8a%e8%b0%88%e5%85%b5' class='tag-link-62' title='2个话题' style='font-size: 9.8pt;'>“指”上谈兵</a>
<a href='http://www.ityran.com/archives/tag/%e5%86%85%e5%ad%98%e7%ae%a1%e7%90%86' class='tag-link-105' title='2个话题' style='font-size: 9.8pt;'>内存管理</a>
<a href='http://www.ityran.com/archives/tag/%e5%a1%94%e9%98%b2%e6%b8%b8%e6%88%8f%e6%95%99%e7%a8%8b' class='tag-link-47' title='10个话题' style='font-size: 15.4pt;'>塔防游戏教程</a>
<a href='http://www.ityran.com/archives/tag/%e5%a6%82%e4%bd%95%e7%9a%84%e4%bd%bf%e7%94%a8%e5%a4%96%e9%83%a8%e5%8f%98%e9%87%8f' class='tag-link-52' title='1个话题' style='font-size: 8pt;'>如何的使用外部变量</a>
<a href='http://www.ityran.com/archives/tag/%e5%ae%9a%e6%97%b6%e5%99%a8' class='tag-link-173' title='3个话题' style='font-size: 11pt;'>定时器</a>
<a href='http://www.ityran.com/archives/tag/%e5%bd%93%e7%a8%8b%e5%ba%8f%e5%b4%a9%e6%ba%83%e7%9a%84%e6%97%b6%e5%80%99%e6%80%8e%e4%b9%88%e5%8a%9e' class='tag-link-48' title='1个话题' style='font-size: 8pt;'>当程序崩溃的时候怎么办</a>
<a href='http://www.ityran.com/archives/tag/%e6%88%98%e4%ba%89%e8%bf%b7%e9%9b%be' class='tag-link-152' title='4个话题' style='font-size: 12pt;'>战争迷雾</a>
<a href='http://www.ityran.com/archives/tag/%e6%8e%a8%e9%80%81%e9%80%9a%e7%9f%a5%e6%95%99%e7%a8%8b' class='tag-link-36' title='1个话题' style='font-size: 8pt;'>推送通知教程</a>
<a href='http://www.ityran.com/archives/tag/%e6%b3%b0%e7%84%b6' class='tag-link-146' title='3个话题' style='font-size: 11pt;'>泰然</a>
<a href='http://www.ityran.com/archives/tag/%e7%a8%8b%e5%ba%8f%e5%b4%a9%e6%ba%83' class='tag-link-50' title='1个话题' style='font-size: 8pt;'>程序崩溃</a>
<a href='http://www.ityran.com/archives/tag/%e7%b1%bb%e4%bc%bcdnf' class='tag-link-116' title='2个话题' style='font-size: 9.8pt;'>类似DNF</a>
<a href='http://www.ityran.com/archives/tag/%e8%80%81g' class='tag-link-145' title='20个话题' style='font-size: 18.2pt;'>老G</a>
<a href='http://www.ityran.com/archives/tag/%e8%a7%86%e9%a2%91%e6%95%99%e7%a8%8b' class='tag-link-128' title='8个话题' style='font-size: 14.5pt;'>视频教程</a>
<a href='http://www.ityran.com/archives/tag/%e8%ae%be%e8%ae%a1%e6%a8%a1%e5%bc%8f' class='tag-link-97' title='3个话题' style='font-size: 11pt;'>设计模式</a>
<a href='http://www.ityran.com/archives/tag/%e8%bd%ac%e6%8d%a2%e5%92%8c%e5%bd%95%e9%9f%b3' class='tag-link-42' title='1个话题' style='font-size: 8pt;'>转换和录音</a>
<a href='http://www.ityran.com/archives/tag/%e8%bf%87%e5%85%b3%e6%b8%b8%e6%88%8f' class='tag-link-112' title='2个话题' style='font-size: 9.8pt;'>过关游戏</a>
<a href='http://www.ityran.com/archives/tag/%e9%9f%b3%e9%a2%91%e5%bc%80%e5%8f%91' class='tag-link-37' title='1个话题' style='font-size: 8pt;'>音频开发</a>
<a href='http://www.ityran.com/archives/tag/%e9%9f%b3%e9%a2%91%e5%bc%80%e5%8f%91%e6%95%99%e7%a8%8b' class='tag-link-43' title='1个话题' style='font-size: 8pt;'>音频开发教程</a>
<a href='http://www.ityran.com/archives/tag/%e9%9f%b3%e9%a2%91%e6%95%99%e7%a8%8b' class='tag-link-41' title='3个话题' style='font-size: 11pt;'>音频教程</a>
<a href='http://www.ityran.com/archives/tag/%e9%9f%b3%e9%a2%91%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%ef%bc%8c%e9%9f%b3%e9%a2%91%e6%96%87%e4%bb%b6' class='tag-link-38' title='1个话题' style='font-size: 8pt;'>音频数据类型，音频文件</a></div>
</div><div class="widget box row"><h3>最新评论</h3><ul class="ds-recent-comments" data-num-items="5" data-show-avatars="1" data-show-time="1" data-show-title="1" data-show-admin="1" data-avatar-size="30" data-excerpt-length="20"></ul></div><script>
if (typeof DUOSHUO !== 'undefined')
	DUOSHUO.RecentComments && DUOSHUO.RecentComments('.ds-recent-comments');
</script><div class="widget box row"><h3>泰然教程组成员</h3>			<div class="textwidget"><table border="3" cellspacing="0" cellpadding="2" width="225"><tbody>
    <tr>
      <td valign="top" width="117"><a href="http://www.ityran.com/about#iven"><img src="http://www.ityran.com/wp-content/uploads/2012/03/P30317-145034-001-150x150.jpg" width="108" height="108" /></a></td>

      <td valign="top" width="102"><a href="http://www.ityran.com/about#子龙山人"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image020-150x150.gif" width="108" height="108" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="117"><a href="http://www.ityran.com/about#sile"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image002-147x150.jpg" width="108" height="110" /></a></td>

      <td valign="top" width="102"><a href="http://www.ityran.com/about#TXX"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image024-150x150.jpg" width="108" height="108" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="117"><a href="http://www.ityran.com/about#Vivi(蓝羽)"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image013-150x150.jpg" width="109" height="109" /></a></td>

      <td valign="top" width="102"><a href="http://www.ityran.com/about#丫头"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image004-150x150.gif" width="108" height="108" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="117"><a href="http://www.ityran.com/about#outman"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image008-150x150.gif" width="110" height="110" /></a></td>

      <td valign="top" width="102"><a href="http://www.ityran.com/about#qq963922432"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image012-150x150.gif" width="108" height="108" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="117"><a href="http://www.ityran.com/about#Benna"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image016-150x150.gif" width="110" height="110" /></a></td>

      <td valign="top" width="102"><a href="http://www.ityran.com/about#Butterfly"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image018-150x150.gif" width="109" height="109" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="117"><a href="http://www.ityran.com/about#大侠自来也"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image022-150x150.gif" width="110" height="110" /></a></td>

      <td valign="top" width="102"><a href="http://www.ityran.com/about#无敌葫芦娃论坛"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image006-139x150.gif" width="110" height="119" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="117"><a href="http://www.ityran.com/about#jesse"><img src="http://www.ityran.com/wp-content/uploads/2012/03/jesse-150x150.jpg" width="111" height="111" /></a></td>

      <td valign="top" width="102"><a href="http://www.ityran.com/about#sharyu"><img src="http://www.ityran.com/wp-content/uploads/2012/03/123_%E5%89%AF%E6%9C%AC.jpg" width="109" height="112" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="102"><a href="http://www.ityran.com/about#李延波"><img src="http://www.ityran.com/wp-content/uploads/2012/03/DB34463FAE84656.223F0450-150x150.png" width="109" height="112" /></a></td>

      <td valign="top" width="117"><a href="http://www.ityran.com/about#linn"><img src="http://www.ityran.com/wp-content/uploads/2012/03/IMG_4019-150x150.jpg" width="109" height="112" /></a></td>
    </tr>

<tr>
      <td valign="top" width="102"><a href="http://www.ityran.com/about#浅底"><img src="http://www.ityran.com/wp-content/uploads/2012/03/1%E5%AF%B8%E7%85%A7%E7%89%87.png" width="109" height="112" /></a></td>

      <td valign="top" width="117"><a href="http://www.ityran.com/about#无脑码农"><img src="http://www.ityran.com/wp-content/uploads/2012/03/%E6%97%A0%E8%84%91%E7%A0%81%E5%86%9C-150x150.jpg" width="109" height="112" /></a></td>
    </tr>
<tr>
      <td valign="top" width="102"><a href="http://www.ityran.com/about#阳光游子"><img src="http://www.ityran.com/wp-content/uploads/2012/03/http_imgload-150x150.jpg" width="109" height="112" /></a></td>

      <td valign="top" width="117"><a href="http://www.ityran.com/about#路上朋友"><img src="http://www.ityran.com/wp-content/uploads/2012/03/lushangpengyou-150x150.jpg" width="109" height="112" /></a></td>
    </tr>
<tr>
      <td valign="top" width="102"><a href="http://www.ityran.com/about#杨世玲"><img src="http://www.ityran.com/wp-content/uploads/2012/03/avatar150.png" width="109" height="112" /></a></td>

      <td valign="top" width="117"><a href="http://www.ityran.com/about#沈大海"><img src="http://www.ityran.com/wp-content/uploads/2012/03/%E6%B2%88%E5%A4%A7%E6%B5%B7.jpg" width="109" height="112" /></a></td>
    </tr>
<tr>
      <td valign="top" width="102"><a href="http://www.ityran.com/about#笨木头"><img src="http://www.ityran.com/wp-content/uploads/2012/03/%E7%85%A7%E7%89%872-150x150.png" width="109" height="112" /></a></td>

      <td valign="top" width="117"><a href="一叶"><img src="http://www.ityran.com/wp-content/uploads/2012/03/yiye-150x150.jpg" width="109" height="112" /></a></td>
    </tr>
  </tbody></table>
</div>
		</div><div class="widget box row"><h3>泰然论坛管理成员</h3>			<div class="textwidget"><table border="3" cellspacing="0" cellpadding="2" width="229"><tbody>
    <tr>
      <td valign="top" width="58"><a href="http://www.ityran.com/about#taiyangmobile"><img src="http://www.ityran.com/wp-content/uploads/2012/03/IMG_0276-150x150.jpg" width="111" height="111" /></a></td>

      <td valign="top" width="165"><a href="http://www.ityran.com/about#40k"><img src="http://www.ityran.com/wp-content/uploads/2012/03/40k-150x150.jpg" width="109" height="109" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="58"><a href="http://www.ityran.com/about#公子"><img src="http://www.ityran.com/wp-content/uploads/2012/03/%E6%9C%AA%E5%91%BD%E5%90%8D-150x150.jpg" width="111" height="111" /></a></td>

      <td valign="top" width="165"><a href="http://www.ityran.com/about#风云永杰"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image001-150x150.png" width="110" height="110" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="58"><a href="http://www.ityran.com/about#apiter"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image003-150x150.png" width="113" height="113" /></a></td>

      <td valign="top" width="165"><a href="http://www.ityran.com/about#葉希&middot;魚"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image005-150x150.png" width="112" height="112" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="58"><a href="http://www.ityran.com/about#王帅"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image009-150x150.png" width="112" height="112" /></a></td>

      <td valign="top" width="165"><a href="http://www.ityran.com/about#菜花"><img src="http://www.ityran.com/wp-content/uploads/2012/03/image011-150x150.png" width="111" height="111" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="165"><a href="http://www.ityran.com/about#edwardair "><img src="http://www.ityran.com/wp-content/uploads/2012/03/edwardair-150x150.jpg" width="111" height="111" /></a></td>

      <td valign="top" width="165"><a href="http://www.ityran.com/about"><img src="http://www.ityran.com/wp-content/uploads/2013/07/u0u0.jpg" width="111" height="111" /></a></td>
    </tr>
  </tbody></table></div>
		</div><div class="widget box row"><h3>泰然技术组成员</h3>			<div class="textwidget"><table border="3" cellspacing="0" cellpadding="2" width="229"><tbody>
    <tr>
      <td valign="top" width="58"><a href="http://www.ityran.com/about#larry "><img src="http://www.ityran.com/wp-content/uploads/2012/03/A4035B296CD4F-150x129.png" width="111" height="111" /></a></td>

      <td valign="top" width="165"><a href="http://www.ityran.com/about#i`m zxc"><img src="http://www.ityran.com/wp-content/uploads/2012/03/03EF4401F0DD140F-150x150.png" width="109" height="109" /></a></td>
    </tr>

    <tr>
      <td valign="top" width="58"><a href="http://www.ityran.com/about#小松鼠"><img src="http://www.ityran.com/wp-content/uploads/2012/03/%E6%A8%8A%E6%B5%B7%E6%9D%BE%E7%9B%B8%E7%89%87-120x150.jpg" width="111" height="111" /></a></td>

      <td>&nbsp;</td>
    </tr>
  </tbody></table></div>
		</div>	<div id="sidebar-follow">
		</div>
</div>    	<div class="mainleft"  id="content">
			<div class="article_container row  box">
				<h1>Cocos2d-x 多分辨率适配完全解析</h1>
				<div class="article_info">
                	<span class="info_author info_ico">u0u0</span> 
                    <span class="info_category info_ico"><a href="http://www.ityran.com/archives/category/cocos2d-x" title="查看cocos2d-x中的全部文章" rel="category tag">cocos2d-x</a></span> 
                    <span class="info_date info_ico">08-04</span>
                    <span class="info_views info_ico">65078</sapn></span>
                    <span class="info_comment info_ico"><a href="http://www.ityran.com/archives/4809#comments" class="ds-thread-count" data-thread-key="4809" title="《Cocos2d-x 多分辨率适配完全解析》上的评论">2</a></span>
				</div>
            	<div class="clear"></div>
            <div class="context">
				<div id="post_content"><p class="icl_post_in_other_langs">Read as other languages：<a href="http://www.ityran.com/en/archives/4914">英语</a></p><p style="text-align: center;"><span style="color: #008000;">u0u0（<a href="http://weibo.com/lkncastle" target="_blank"><span style="color: #008000;">微博</span></a>）原创，首发于泰然，转载请著名出处。</span></p>
<h2>overview</h2>
<p>从Cocos2d-x 2.0.4开始，Cocos2d-x提出了自己的多分辨率支持方案，废弃了之前的retina相关设置接口，提出了design resolution概念。<br />
有以下相关接口：</p>
<pre class="wp-code-highlight prettyprint linenums:1">CCEGLView::sharedOpenGLView()-&gt;setDesignResolutionSize() //设计分辨率大小及模式
CCDirector::sharedDirector()-&gt;setContentScaleFactor() //内容缩放因子
CCFileUtils::sharedFileUtils()-&gt;setResourceDirectory() //deprecated
CCFileUtils::sharedFileUtils()-&gt;setSearchPaths() //资源搜索路径
CCEGLView::sharedOpenGLView()-&gt;getFrameSize() //屏幕分辨率
CCDirector::sharedDirector()-&gt;getWinSize() //设计分辨率
CCDirector::sharedDirector()-&gt;getVisibleSize() //设计分辨率可视区域大小
CCDirector::sharedDirector()-&gt;getVisibleOrigin() //设计分辨率可视区域起点</pre>
<p>从cocos2d-2.1beta3-x-2.1.1开始，<br />
<del>CCFileUtils::sharedFileUtils()-&gt;setResourceDirectory()</del><br />
被新接口<br />
CCFileUtils::sharedFileUtils()-&gt;setSearchPaths(searchPath)<br />
替代</p>
<p>从Cocos2d-x 2.1.3开始，新加入了两种ResolutionPolicy（kResolutionFixedHeight， kResolutionFixedWidth），共5中模式。</p>
<p>官方分别在<a href="http://www.cocos2d-x.org/projects/Cocos2d-x/wiki/Multi_resolution_support">Multi_resolution_support </a>和 <a href="http://www.cocos2d-x.org/projects/Cocos2d-x/wiki/Mechanism_of_loading_resources">Mechanism_of_loading_resources</a>有介绍。</p>
<p>本文从引擎使用者角度分析Cocos2d-x的多分辨率适配技术。</p>
<h2>从Retina 到 design resolution</h2>
<p>在Cocos2d-x 2.0.4之前，有Retina的概念，这个是从cocos2d-iphone过来的概念。</p>
<p>cocos2d-iphone为了支持Retina iphone 设备，使用了-hd等后缀来区分iphone和Retine iphone的图片资源。在设计游戏的时候，使用point 坐标系，而非真正的pixel坐标系。这点和iOS native应用开发提出的point概念一至，不用修改代码，就能在640&#215;960的设备上跑之前320&#215;480的程序，只是图片会看起来模糊，一旦加入@2x的图片，iOS自动加载@2x的图片，实现对Retna iphone的支持。</p>
<p>point坐标系，在一定范围内能解决多分辨率支持的问题。但是当iphone5，ipad 3出来以后，iOS总共有5个分辨率需要支持，如果做一个universal的程序，是相当痛苦的。point坐标系并不能完全解决问题，android上的分辨率情况更加复杂。</p>
<p>design resolution应该是从point坐标系进化过来的概念，目的是屏蔽设备分辨率，精灵坐标都在design resolution上布局，但要实现这个目标并不简单。Cocos2d-x提供了一组相关的接口和5种分辨率适配策略，哪种策略才是我们需要的，下面我们一同探寻。</p>
<h2>资源分辨率，设计分辨率，屏幕分辨率</h2>
<blockquote><p>Resources width 以下简写为RW，Resources height 以下简写为RH</p>
<p>Design width 以下简写为DW，Design height 以下简写为DH</p>
<p>Screen width 以下简写为SW，Screen height 以下简写为SH</p></blockquote>
<p>在SDK的samples中有个HelloCpp项目。展示了如何使用多分辨率方案。<br />
以下以HelloCpp的AppMacros.h配置基本相同，但是交换了宽高的数值，以竖屏游戏为例子。</p>
<p>Cocos2d-x图片显示有下面两个逻辑过程。<br />
资源布局到 到 设计分辨率，设计分辨率 布局到 屏幕。</p>
<p>如下图所示：</p>
<p><a href="http://www.ityran.com/wp-content/uploads/2013/08/overview.png" class="pirobox_gall" title="Cocos2d-x 多分辨率适配完全解析"><img class="alignnone size-full wp-image-4812" alt="overview" src="http://www.ityran.com/wp-content/uploads/2013/08/overview.png" alt="Cocos2d-x 多分辨率适配完全解析" width="1021" height="339" /></a></p>
<p>接口setContentScaleFactor()和setSearchPaths()控制着第一个转换过程。<br />
而setDesignResolutionSize()控制第二个过程。两个过程结合在一起，影响最终的显示效果。</p>
<h2>从资源分辨率到设计分辨率</h2>
<p>setSearchPaths()需要根据当前屏幕分辨率做恰当的设置，HelloCpp展示了一套简单方案，但可能不是最佳的。</p>
<p>setContentScaleFactor()决定了图片显示到屏幕的缩放因子，但是这个接口的参数不是通过资源图片的宽、高比屏幕宽、高得来。Cocos2d-x引擎设计试图屏蔽游戏开发者直接去关注屏幕，所以这个因子是资源宽、高比设计分辨率宽、高。</p>
<p>setContentScaleFactor()通常有两个方式来设置参数。<br />
RH/DH或RW/DW，不同的因子选择有不同的缩放负作用。<br />
先看一张图:<br />
<a href="http://www.ityran.com/wp-content/uploads/2013/08/contentScaleFactor.png" class="pirobox_gall" title="Cocos2d-x 多分辨率适配完全解析"><img class="alignnone size-full wp-image-4811" alt="contentScaleFactor" src="http://www.ityran.com/wp-content/uploads/2013/08/contentScaleFactor.png" alt="Cocos2d-x 多分辨率适配完全解析" width="767" height="526" /></a><br />
用高度比作为内容缩放因子，保证了背景资源的垂直方向在设计分辨率范围内的全部显示。</p>
<p>用宽度比作为内容缩放因子，保证了背景资源的水平方向在设计分辨率范围内的全部显示。</p>
<h2>从设计分辨率到屏幕分辨率</h2>
<p>setDesignResolutionSize(DW, DH, resolutionPolicy)<br />
有三个参数，设计分辨率宽，设计分辨率高，分辨率策略。<br />
前两个很好理解，复杂点在分辨率策略的选择上。</p>
<p>先来看kResolutionExactFit，kResolutionNoBorder，kResolutionShowAll这三种情况，2.1.3新加入的策略稍后分析。<br />
三种策略的设计分辨率都是传入值，内部不做修正。</p>
<p>先看一张图：</p>
<p><a href="http://www.ityran.com/wp-content/uploads/2013/08/setDesignResolutionSize.png" class="pirobox_gall" title="Cocos2d-x 多分辨率适配完全解析"><img class="alignnone size-full wp-image-4814" alt="setDesignResolutionSize" src="http://www.ityran.com/wp-content/uploads/2013/08/setDesignResolutionSize.png" alt="Cocos2d-x 多分辨率适配完全解析" width="753" height="846" /></a></p>
<p>kResolutionShowAll</p>
<blockquote><p>屏幕宽、高分别和设计分辨率宽、高计算缩放因子，取较(小)者作为宽、高的缩放因子。保证了设计区域全部显示到屏幕上，但可能会有黑边。</p></blockquote>
<p>kResolutionExactFit</p>
<blockquote><p>屏幕宽 与 设计宽比 作为X方向的缩放因子，屏幕高 与 设计高比 作为Y方向的缩放因子。保证了设计区域完全铺满屏幕，但是可能会出现图像拉伸。</p></blockquote>
<p>kResolutionNoBorder</p>
<blockquote><p>屏幕宽、高分别和设计分辨率宽、高计算缩放因子，取较(大)者作为宽、高的缩放因子。保证了设计区域总能一个方向上铺满屏幕，而另一个方向一般会超出屏幕区域。</p></blockquote>
<p>kResolutionNoBorder是之前官方推荐使用的方案，他没有拉伸图像，同时在一个方向上撑满了屏幕，但是2.1.3新加入的两种策略将撼动kResolutionNoBorder的地位。</p>
<p>kResolutionFixedHeight和kResolutionFixedWidth都是会在内部修正传入设计分辨率，以保证屏幕分辨率到设计分辨率无拉伸铺满屏幕。<br />
如图：<br />
<a href="http://www.ityran.com/wp-content/uploads/2013/08/setDesignResolutionSize-2.png" class="pirobox_gall" title="Cocos2d-x 多分辨率适配完全解析"><img class="alignnone size-full wp-image-4813" alt="setDesignResolutionSize-2" src="http://www.ityran.com/wp-content/uploads/2013/08/setDesignResolutionSize-2.png" alt="Cocos2d-x 多分辨率适配完全解析" width="811" height="552" /></a></p>
<p>kResolutionFixedHeight</p>
<blockquote><p>保持传入的设计分辨率高度不变，根据屏幕分辨率修正设计分辨率的宽度。</p></blockquote>
<p>kResolutionFixedWidth</p>
<blockquote><p>保持传入的设计分辨率宽度不变，根据屏幕分辨率修正设计分辨率的高度。</p></blockquote>
<h2>结合两个过程</h2>
<p>第一过程有两种情况，第二过程有5种情况，在一个分辨率下会有10种可能的方案组合。<br />
如何选择自己需要的？<br />
我们需要作出选择，是牺牲效果还是牺牲部分显示区域。</p>
<p>这里我们选者牺牲一个方向的显示区域为例，结果说明两个过程。<br />
在我的游戏里面，背景图的高需要全部显示，而宽方向可以裁减。</p>
<p>要实现这个目的，需要保证两个过程都是在宽方向裁减。</p>
<ul>
<li>第一过程选择 setContentScaleFactor(RH/DH)</li>
<li>第二过程有两个选择：kResolutionNoBorder和kResolutionFixedHeight</li>
</ul>
<p>为了说明两者的区别，需要结合VisibleOrigin和VisibleSize。<br />
看图</p>
<p><a href="http://www.ityran.com/wp-content/uploads/2013/08/visible.png" class="pirobox_gall" title="Cocos2d-x 多分辨率适配完全解析"><img class="alignnone size-full wp-image-4815" alt="visible" src="http://www.ityran.com/wp-content/uploads/2013/08/visible.png" alt="Cocos2d-x 多分辨率适配完全解析" width="693" height="915" /></a></p>
<p>kResolutionNoBorder情况下，设计分辨率并不是可见区域，我们布局精灵需要根据VisibleOrigin和VisibleSize来做判断处理。</p>
<p>而kResolutionFixedHeight则不同，设计分辨率就是可见区域，VisibleOrigin总是(0,0)<br />
getVisibleSize() = getWinSize()，kResolutionFixedHeight达到了同样的目的，但是却简化了代码。</p>
<p>kResolutionFixedHeight和kResolutionFixedWidth是kResolutionNoBorder的进化，新项目中建议立即开始使用这两种方式。</p>
<h2>小结</h2>
<p>kResolutionFixedHeight</p>
<blockquote><p>适合高方向需要撑满，宽方向可裁减的游戏，结合setContentScaleFactor(RH/DH)使用。</p></blockquote>
<p>kResolutionFixedWidth</p>
<blockquote><p>适合宽方向需要撑满，高方向可裁减的游戏，结合setContentScaleFactor(RW/DW)使用。</p></blockquote>
<p>tip:正确设置AppMacros.h里面的宽高，注意横屏游戏和竖屏游戏的不同。</p>
</div>
                &nbsp;               	<div class="clear"></div>
                
                <div class="article_tags">
                	<div class="tagcloud">
                    	标签：<a href="http://www.ityran.com/archives/tag/cocos2d-x-2" rel="tag">Cocos2D-x</a> <a href="http://www.ityran.com/archives/tag/%e5%a4%9a%e5%88%86%e8%be%a8%e7%8e%87" rel="tag">多分辨率</a>                    </div>
                </div>
                                <div class="baishare">
                <!-- Baidu Button BEGIN -->
    				<div id="bdshare" class="bdshare_t bds_tools_32 get-codes-bdshare">
        				<a class="bds_tsina"></a>
						<a class="bds_qzone"></a>
        				<a class="bds_tqq"></a>
						<a class="bds_renren"></a>
        				<a class="bds_t163"></a>
        				<a class="bds_tfh"></a>
        				<a class="bds_tsohu"></a>
        				<a class="bds_tuita"></a>
        				<a class="bds_hi"></a>
        				<a class="bds_ty"></a>
        				<a class="bds_baidu"></a>
        				<a class="bds_tieba"></a>
        				<a class="bds_fx"></a>
        				<a class="bds_diandian"></a>
        				<span class="bds_more">更多</span>
    				</div>
				<!-- Baidu Button END -->
                </div>
                 	             </div>
		</div>
        
    	<div>
		<ul class="post-navigation row">
			<div class="post-previous twofifth">
				上一篇 <br> <a href="http://www.ityran.com/archives/4750" rel="prev">CCScrollView 实现帮助界面、关卡选择</a>            </div>
            <div class="post-next twofifth">
				下一篇 <br> <a href="http://www.ityran.com/archives/4765" rel="next">如何使用 CocoStudio 场景编辑器制作《魔卡幻想》主界面</a>            </div>
        </ul>
	</div>
     
	<div class="article_container row  box article_related">
    	<div class="related">
		<ul>
		<li class="related_box"  >
			<a href="http://www.ityran.com/archives/5185" title="JSB内存管理" target="_blank">
			<div class="r_pic">
                 			</div>
			<div class="r_title">
					JSB内存管理            </div>
            </a>
		</li>
			<li class="related_box"  >
			<a href="http://www.ityran.com/archives/4425" title="Cocos2d-x 之 CCGUI设计与实现" target="_blank">
			<div class="r_pic">
                 <img src="http://www.ityran.com/wp-content/themes/Loostrive/timthumb.php?src=http://www.ityran.com/wp-content/uploads/2013/07/ccgui-1-300x79.png&amp;h=90&amp;w=140&amp;zc=1" alt="Cocos2d-x 之 CCGUI设计与实现" />			</div>
			<div class="r_title">
					Cocos2d-x 之 CCGUI设计与实现            </div>
            </a>
		</li>
			<li class="related_box"  >
			<a href="http://www.ityran.com/archives/4174" title="【笨木头Lua专栏】基础补充01：巧说table的几种构造方式" target="_blank">
			<div class="r_pic">
                 <img src="http://www.ityran.com/wp-content/themes/Loostrive/timthumb.php?src=http://www.ityran.com/wp-content/uploads/2013/04/cocos2d-x1.png&amp;h=90&amp;w=140&amp;zc=1" alt="【笨木头Lua专栏】基础补充01：巧说table的几种构造方式" />			</div>
			<div class="r_title">
					【笨木头Lua专栏】基础补充01：巧说table的几种构造方式            </div>
            </a>
		</li>
			<li class="related_box"  >
			<a href="http://www.ityran.com/archives/4161" title="【Software MyZone 专栏】RPG游戏心得" target="_blank">
			<div class="r_pic">
                 <img src="http://www.ityran.com/wp-content/themes/Loostrive/timthumb.php?src=http://www.ityran.com/wp-content/uploads/2013/04/cocos2d-x1.png&amp;h=90&amp;w=140&amp;zc=1" alt="【Software MyZone 专栏】RPG游戏心得" />			</div>
			<div class="r_title">
					【Software MyZone 专栏】RPG游戏心得            </div>
            </a>
		</li>
			<li class="related_box"  >
			<a href="http://www.ityran.com/archives/4126" title="【笨木头原创专栏】一个函供应多个菜单回调——UserObject自定义数据" target="_blank">
			<div class="r_pic">
                 <img src="http://www.ityran.com/wp-content/themes/Loostrive/timthumb.php?src=http://www.ityran.com/wp-content/uploads/auto_save_image/2013/05/113839UtT.jpg&amp;h=90&amp;w=140&amp;zc=1" alt="【笨木头原创专栏】一个函供应多个菜单回调——UserObject自定义数据" />			</div>
			<div class="r_title">
					【笨木头原创专栏】一个函供应多个菜单回调——UserObject自定义数据            </div>
            </a>
		</li>
			<li class="related_box"  >
			<a href="http://www.ityran.com/archives/4100" title="【无间落叶 专栏】Cocos2d-x 内存管理浅说" target="_blank">
			<div class="r_pic">
                 <img src="http://www.ityran.com/wp-content/themes/Loostrive/timthumb.php?src=http://www.ityran.com/wp-content/uploads/2013/04/cocos2d-x1.png&amp;h=90&amp;w=140&amp;zc=1" alt="【无间落叶 专栏】Cocos2d-x 内存管理浅说" />			</div>
			<div class="r_title">
					【无间落叶 专栏】Cocos2d-x 内存管理浅说            </div>
            </a>
		</li>
	</ul>       	</div>
	</div>
         	<div class="clear"></div>
	<div id="comments_box">
		<a name="comments"></a>

<div class="ds-thread" data-thread-key="4809" data-author-key="23" data-title="Cocos2d-x 多分辨率适配完全解析" data-url="http://www.ityran.com/archives/4809"></div>

<script type="text/javascript">
	if (typeof DUOSHUO !== 'undefined')
		DUOSHUO.EmbedThread('.ds-thread');
</script>
	<div id="ds-ssr">

		
            <ol id="commentlist">
                		<li class="comment even thread-even depth-1" id="li-comment-632">
			<article id="comment-632" class="comment">
				<footer class="comment-meta">
					<cite class="comment-author vcard">
						<span class="fn"><a href='http://t.qq.com/evamango' rel='external nofollow' class='url'>黄启波</a></span> on <a rel="nofollow" href="http://www.ityran.com/archives/4809/comment-page-1#comment-632"><time pubdate datetime="2013-12-05T13:03:16+00:00">2013 年 12 月 5 日 at 下午 1:03</time></a> <span class="says">said:</span>					</cite><!-- .comment-author .vcard -->
				</footer>
	
				<div class="comment-content"><p>长姿势了,赞!!</p>
</div>
				
			</article><!-- #comment-## -->
		</li><!-- #comment-## -->
		<li class="comment odd alt thread-odd thread-alt depth-1" id="li-comment-508">
			<article id="comment-508" class="comment">
				<footer class="comment-meta">
					<cite class="comment-author vcard">
						<span class="fn">cpp-Muli</span> on <a rel="nofollow" href="http://www.ityran.com/archives/4809/comment-page-1#comment-508"><time pubdate datetime="2013-10-16T16:51:16+00:00">2013 年 10 月 16 日 at 下午 4:51</time></a> <span class="says">said:</span>					</cite><!-- .comment-author .vcard -->
				</footer>
	
				<div class="comment-content"><p>goood</p>
</div>
				
			</article><!-- #comment-## -->
		</li><!-- #comment-## -->
            </ol>

		            
    </div>    </div>
	</div>
</div>
	<!--WP Code Highlight_start-->
	<script type="text/javascript">
		window.onload = function(){prettyPrint();};
	</script>
	<script type="text/javascript" src="http://www.ityran.com/wp-content/plugins/wp-code-highlight/js/wp-code-highlight.js"></script>
	<!--WP Code Highlight_end-->
<div class="clear"></div>
<div id="footer">
          <div class="copyright">
  <p> Copyright &copy; 2012-2013 <a href="http://www.ityran.com/"><strong>
    泰然网    </strong></a> Powered by <a href="http://www.wordpress.org/" rel="external">WordPress</a><br />
        <a href="http://www.miitbeian.gov.cn/" rel="external">蜀ICP备12001964号-3</a>
    .            <script src="http://s11.cnzz.com/stat.php?id=3413370&web_id=3413370" language="JavaScript"></script>           </p>
  <!-- <p class="author"><a href="http://www.loome.net/" target="_blank" rel="external">Theme By Loome</a></p> -->
  </div>
</div>
</div>
<!--gototop-->
<div id="tbox">
    <a id="home" href="http://www.ityran.com"></a>
      <a id="pinglun" href="#comments_box"></a>
    <a id="gotop" href="javascript:void(0)"></a> </div>
<script type="text/javascript" src="http://www.ityran.com/wp-content/themes/Loostrive/js/loostrive.js"></script>
<script type="text/javascript" src="http://www.ityran.com/wp-content/themes/Loostrive/comments-ajax.js"></script> 
<script type="text/javascript" src="http://www.ityran.com/wp-content/themes/Loostrive/js/realgravatar.js"></script> 
<script type="text/javascript" src="http://www.ityran.com/wp-content/themes/Loostrive/images/lightbox/pirobox.js"></script>
<!--百度分享--> 
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1109819" ></script> 
<script type="text/javascript" id="bdshell_js"></script> 
<script type="text/javascript">
	document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + new Date().getHours();
</script> 
<!--百度分享结束-->
 <div id="su-footer-links" style="text-align: center;"></div>
                <div id="lang_sel_footer">
                    <ul>
                        <li><a rel="alternate" hreflang="zh-hans" href="http://www.ityran.com/archives/4809" class="lang_sel_sel"><img src="http://www.ityran.com/wp-content/plugins/sitepress-multilingual-cms/res/flags/zh-hans.png" alt="zh-hans" class="iclflag" />&nbsp;<span  class="icl_lang_sel_current">简体中文</span></a></li>
                        <li><a rel="alternate" hreflang="en" href="http://www.ityran.com/en/archives/4914"><img src="http://www.ityran.com/wp-content/plugins/sitepress-multilingual-cms/res/flags/en.png" alt="en" class="iclflag" />&nbsp;<span  class="icl_lang_sel_native">English</span> <span  class="icl_lang_sel_translated"><span  class="icl_lang_sel_native">(</span>英语<span  class="icl_lang_sel_native">)</span></span></a></li>
                    </ul>
                </div></body></html>
